package controller.api;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;
import com.jfinal.kit.Ret;

import common.inter.ServicerStationInter;
import common.inter.StaffStationInter;
import model.MonitoringFactor;
import service.MonitoringFactorService;

public class ApiMonitoringFactorController extends BaseApiController {
	@Inject MonitoringFactorService monitoringFactorService ;

	@Before(ServicerStationInter.class)
	public void list() {
	    Kv kv = getParamKv() ;
	    kv.set("tmf.stationId", getStation().getId());
	    Integer pageNumber = getParaToInt("pageNumber", 1);
	    Integer pageSize = getParaToInt("pageSize", 10);
	    set("page", monitoringFactorService.getApiPage( kv , pageNumber, pageSize));
	    renderJson();
	}

	@Before(StaffStationInter.class)
	public void save() {
		MonitoringFactor monitoringFactor = getModel(MonitoringFactor.class , "x");
        Ret ret = monitoringFactorService.save(monitoringFactor , getStation() , getStaff() );
        renderJson(ret);
	}
	
	@Before(StaffStationInter.class)
	public void delete() {
		Long mId = getParaToLong("mId");
        Ret ret = monitoringFactorService.delete( mId );
        renderJson(ret);
	}
}
